<!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<kd-content-card>
  <kd-content>
    <kd-resource-card-list selectable="false"
                           with-statuses="false"
                           select-id="{{::$ctrl.getSelectId()}}"
                           list="$ctrl.endpointList"
                           list-resource="$ctrl.endpointListResource">
      <kd-resource-card-list-header>
        <kd-resource-card-list-title>
          [[Endpoints|Label which appears above the list of such objects.]]
        </kd-resource-card-list-title>
      </kd-resource-card-list-header>
      <kd-zero-state ng-if="!$ctrl.hasEndpoints()">
        <kd-zero-state-text>
          [[There are currently no Endpoints selected by this Service.]]
        </kd-zero-state-text>
      </kd-zero-state>
      <kd-resource-card-header-columns ng-show="$ctrl.hasEndpoints()">
        <kd-resource-card-header-column>
          [[Host|Label 'Source' for the endpoint source column of the endpoints table (endpoints list page).]]
        </kd-resource-card-header-column>
        <kd-resource-card-header-column>
          [[Ports (Name, Port, Protocol)|Label 'Sub-object' for the respective column of the endpoints table (endpoints list page).]]
        </kd-resource-card-header-column>
        <kd-resource-card-header-column>
          [[Node|Label 'Sub-object' for the respective column of the endpoints table (endpoints list page).]]
        </kd-resource-card-header-column>
        <kd-resource-card-header-column>
          [[Ready |Label 'Sub-object' for the respective column of the endpoints table (endpoints list page).]]
        </kd-resource-card-header-column>
      </kd-resource-card-header-columns>
      <kd-resource-card dir-paginate="endpoint in $ctrl.endpointList.endpoints | itemsPerPage: default"
                        total-items="::$ctrl.endpointList.listMeta.totalItems"
                        object-meta="endpoint.objectMeta"
                        type-meta="endpoint.typeMeta"
                        pagination-id="{{::$ctrl.getSelectId()}}">
        <kd-resource-card-columns>
          <kd-resource-card-column>{{::endpoint.host}}</kd-resource-card-column>
          <kd-resource-card-column>
            <div ng-repeat="port in endpoint.ports">
              <div ng-if="port.name">
                <kd-middle-ellipsis display-string="{{::port.name}}, {{::port.port}}, {{::port.protocol}}">
                </kd-middle-ellipsis>
              </div>
              <div ng-if="!port.name">
                <kd-middle-ellipsis display-string="<unset>, {{::port.port}}, {{::port.protocol}}">
                </kd-middle-ellipsis>
              </div>
            </div>
          </kd-resource-card-column>
          <kd-resource-card-column>
            <div ng-if="endpoint.nodeName">{{::endpoint.nodeName}}</div>
            <div ng-if="!endpoint.nodeName">-</div>
          </kd-resource-card-column>
          <kd-resource-card-column>{{::endpoint.ready}}</kd-resource-card-column>
        </kd-resource-card-columns>
      </kd-resource-card>
      <kd-resource-card-list-footer>
        <kd-resource-card-list-pagination></kd-resource-card-list-pagination>
      </kd-resource-card-list-footer>
    </kd-resource-card-list>
  </kd-content>
</kd-content-card>
